package com.tul.exercise.base.readFile;/**
 * Created by 第五天 on 2018/8/22.
 */

import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @ClassName ReadFile
 * @Description TODO
 * @Author tul 2018/8/22
 * @Version 1.0
 **/
public class ReadFile {
    public static void main(String[] args) {
        try {

            String fileName = "D:\\test\\boardId.txt";


            List<String> lineLists = Files
                    .lines(Paths.get(fileName), Charset.defaultCharset())
                    .flatMap(line -> Arrays.stream(line.split("\n")))
                    .collect(Collectors.toList());

            //输出文件函数
            //.out.println("lineLists====" + lineLists.size());

            //输出每一行文件内容
            String str = "";
            lineLists.stream().filter(line -> line.contains("boardID")).collect(Collectors.toList()).stream().forEach(line -> {
                System.out.println(line.split(":")[1] + ",");
            });


        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
